package com.imooc.bigdata.hadoop.hdfs;/**
 * Created by luochangyong on 2019/6/29.
 */

/**
 * 自定义wc实现类
 */
public class CaseIgnoreCountMapper implements ImoocMapper {
    @Override
    public void map(String line, ImoocContext context) {
        String[] words  = line.toLowerCase().split("\t");

        for(String word : words){
            Object value = context.get(word);
            if(value == null){
                context.write(word, 1); //表示没有出现过该单词
            }else{
                int v = Integer.parseInt(value.toString());
                context.write(word, v+1); //去除单词对应的次数+1
            }
        }
    }
}